import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {HomeComponent} from './components/home/home.component'
import {AboutComponent} from './components/about/about.component'
import {DetailComponent} from './components/detail/detail.component'
import {NewsComponent} from './components/news/news.component'
import {ErrorComponent} from './components/error/error.component'
import {MorningComponent} from './components/morning/morning.component'
import { NightComponent } from './components/night/night.component';
const routes: Routes = [
  {
    path:'home',
    component:HomeComponent
  },
  {
    path:"about",
    component:AboutComponent
  },
  {
    path:"detail",
    component:DetailComponent
  },
  {
    path:"news",
    component:NewsComponent,
    children:[
      {
        path:"morning",
        component:MorningComponent
      },{
        path:"night",
        component:NightComponent
      },{
        path:"",
        redirectTo:"morning",
        pathMatch:"full"
      }
    ]
  },
  //路由重定向
  {
    path:"",
    redirectTo:"home",
    //prefixed:全局
    pathMatch:"full"    //严格匹配 必须要加
  },
  //错误路径
  {
    path:"**",
    component:ErrorComponent
  }
]
@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
